
// 类装饰器,参数是类的构造函数
const doc: ClassDecorator = (target: Function) => {
    console.log(target);
    target.prototype.like = 'kele'
}


// 属性装饰器,参数1是类的原型,参数2是属性名
const prop: PropertyDecorator = (target: any, key: string | symbol) => {
    console.log(target, key);
}

// 方法装饰器,参数1是类的原型,参数2是方法名,参数3是属性描述符
const method1: MethodDecorator = (target: any, key: string | symbol, descriptor: PropertyDescriptor) => {
    console.log(target, key, descriptor);
}

// 方法参数装饰器,参数1是类的原型,参数2是方法名,参数3是参数索引
const params: ParameterDecorator = (target: any, key: string | symbol | undefined, index: number) => {
    console.log(target, key, index, '参数装饰器');
    return '参数装饰器'
}



@doc
class Kele {
    @prop
    public name: string
    constructor(name: string) {
        this.name = name
    }

    @method1
    public say(name: string, @params age: number) {
        console.log(name, age);
    }
}

const kele = new Kele('kele')
console.log(kele.say('1', 1));